<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>星星诗词库</title>
<script type="text/javascript">
	function delPoem(id){
		alert(id);
		document.getElementById("poemid").value=id;
		document.getElementById("delbtn").click();
	}
	function showPoem(id){
		document.getElementById("poemid").value=id;
		var a = document.getElementById("showbtn");
		a.click();
	}
</script>

<style type="text/css">
	#poemList td,th{
		width:100px;
		border:1px solid;
	}
</style>
</head>
<body>
<center>
<div>
<h1>星星诗词库</h1>
</div>
<hr>

<f:view>
	<div style="border-style:solid;border-width:1px;width:800px;">
		<h:form prependId="false">
		<table>
		<tr>
		<td align="left">
			模糊搜索：<h:inputText value="#{poemMB.queryWord }"></h:inputText>&nbsp;&nbsp;
			<h:commandButton type="submit" value="搜索" action="#{poemMB.queryPoem }"></h:commandButton>&nbsp;&nbsp;&nbsp;
		</td>
		<td align="right">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<h:commandLink action="#{poemMB.preAdd }" value="诗词入库"></h:commandLink>
		</td>
		</tr>
		</table>
		</h:form>
	</div>
	<br>
	
	<h:form prependId="false">
		<h:inputHidden id="poemid" value="#{poemMB.optId }"></h:inputHidden>
		<h:commandButton id="delbtn" action="#{poemMB.delPoem }" style="display:none;"></h:commandButton>
		<h:commandButton id="showbtn" action="#{poemMB.showPoem }"  style="display:none;"></h:commandButton>
	</h:form>
	<h:dataTable id="poemList" var="item" value="#{poemMB.pc.poemList }" style="border:1px solid;width:800px;">
		<h:column headerClass="tablehead" >
			<f:facet name="header">
				<h:outputText value="标题"></h:outputText>
			</f:facet>
			<h:outputText value="#{item.title }" styleClass="tablehead"></h:outputText>
		</h:column>
		<h:column headerClass="tablehead">
			<f:facet name="header">
				<h:outputText value="作者"></h:outputText>
			</f:facet>
			<h:outputText value="#{item.author }"></h:outputText>
		</h:column>
		<h:column>
			<f:facet name="header">
				<h:outputText value="年代"></h:outputText>
			</f:facet>
			<h:outputText value="#{item.ageStr }" styleClass="tablehead"></h:outputText>
		</h:column>
		<h:column>
			<f:facet name="header">
				<h:outputText value="题材"></h:outputText>
			</f:facet>
			<h:outputText value="#{item.topicStr }" styleClass="tablehead"></h:outputText>
		</h:column>
		<h:column>
			<f:facet name="header">
				<h:outputText value="类型"></h:outputText>
			</f:facet>
			<h:outputText value="#{item.typeStr }" styleClass="tablehead"></h:outputText>
		</h:column>
		
		<h:column>
			<f:facet name="header">
				<h:outputText value="操作"></h:outputText>
			</f:facet>
			<a href="#" onclick='delPoem(<h:outputText value="#{item.id}"/>)'>删除</a>
			<a href="#" onclick='showPoem(<h:outputText value="#{item.id}"/>)'>查看</a>
		</h:column>
	</h:dataTable>
</f:view>
</center>
</body>
</html>